package cn.org.july.weixin.service.message;

import cn.org.july.weixin.common.bean.message.Article;
import cn.org.july.weixin.common.bean.message.ArticleMessage;
import cn.org.july.weixin.common.interfaces.IMessage;
import cn.org.july.weixin.common.interfaces.IMessageData;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 图文消息处理类
 *
 * @auther: wanghongjie
 * @blame: wanghongjie
 * @date: 2020-08-31 22:24
 * @Description:
 */
public class NewsMessageService implements IMessage {
    @Override
    public String handler(Map<String, Object> map, IMessageData data) {
        List<Article> articles = new ArrayList<>();
        Article article = new Article();
        article.setDescription("第二种在添加语言时，根据**排名**将语言插入到相应的位置（如果有这个排名，则添加失败，并给出提示");
        article.setPicUrl("http://blog.julywhj.cn/链表插入示意图2.png?e=9223372038453173273&token=2mXC2bkkH46J1P3XvnecyBPAX1y_K11Je5BYz2t4:c6H3heQuFK3U8xzQg2MKltW9oUQ=");
        article.setTitle("链表插入");
        article.setUrl("https://blog.csdn.net/July_whj/article/details/103148309");
        articles.add(article);
        ArticleMessage articleMessage = ArticleMessage.of(map, articles);
        String from = articleMessage.getFromUserName();
        articleMessage.setFromUserName(articleMessage.getToUserName());
        articleMessage.setToUserName(from);
        articleMessage.setMsgType("news");
        return articleMessage.toXml();
    }
}
